package edu.hcmus.sow.dao;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import edu.hcmus.sow.domain.User;

/**
 * DAO to manage User entities.
 * 
 */
@Repository
@Transactional
public class UserDAOImpl extends AbstractHibernateDAO<User, Integer> implements UserDAO {

   public User findByUsername(String username, Integer clientID) throws DataAccessException {
      List<User> list = findByCriteria(Restrictions.eq("username", username), Restrictions.eq("clientID", clientID));
      return list.size() == 0 ? null : list.get(0);

   }
}
